﻿using System;
using Castle.ActiveRecord;
using System.Collections.Generic;

namespace ElevatorSpeeches.Framework
{
    [Serializable]
    public abstract class EntityBase<T> : ActiveRecordValidationBase<T> where T : class
    {        
        [PrimaryKey]
        public int ID { get; set; }

        public bool IsNew()
        {
            return (ID == 0);
        }

        private List<String> _CustomErrorMessages;
        public List<String> CustomErrorMessages
        {
            get
            {
                if (_CustomErrorMessages == null)
                    _CustomErrorMessages = new List<string>();
                return _CustomErrorMessages;
            }
            set
            {
                _CustomErrorMessages = value;
            }
        }

        public List<string> AllErrorMessages
        {
            get
            {
                List<string> rv = CustomErrorMessages;
                rv.InsertRange(0, ValidationErrorMessages);
                return rv;
            }
        }
    }
}
